{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}
{% import "TopxiaAdminBundle::macro.html.twig" as web_macro %}
{% set modal_class = 'modal-lg' %}
{% block title %}{{ batch.name }}-优惠码使用详情{% endblock %}
{% block body %}

<table class="table table-striped" id="coupon-list">
    <thead>
      <tr>
        <th>优惠码</th>
        <th>状态</th>
        <th>使用者</th>
        <th>订单信息</th>
        <th>原价</th>
        <th>实付</th>
        <th>使用时间</th>
      </tr>
    </thead>
    <tbody>
      {% for coupon in coupons %}
      	{% set user = users[coupon.userId]|default(null) %}
      	{% set order = orders[coupon.orderId]|default(null) %}
		<tr>
		  <td>{{ coupon.code }}</td>
		  <td>{% if coupon.status == 'unused' %}未使用{% else %}已使用{% endif %}</td> 
		  <td>{% if user %}{{ web_macro.user_link(user) }}{% else %}-{% endif %}</td>
		  <td class="text-danger">{{ order.title|default('-') }}</td> 
      <td class="text-danger">{% if order %} {{ order.amount + order.couponDiscount }}{% else %} - {% endif %}</td>
		  <td class="text-danger">{% if order %} {{ order.amount }}元{% else %}{% endif %}</td>
		  <td>
		  	{% if user %}
			  	{{ coupon.orderTime|date('Y-m-d H:i:s') }}
			{% else %}
				-
			{% endif %}
		  </td> 
		</tr>
      {% endfor %}
    </tbody>
  </table>
  {{ web_macro.paginator(paginator) }}

{% endblock %}
{% block footer %}
  <button type="button" class="btn btn-default pull-right" data-dismiss="modal">关闭</button>
{% endblock %} 